<include file="public:header" />
<!--管理员管理-->
<div class="pad_lr_10">
    <div class="J_tablelist table_list" data-source="admin_role" data-acturi="{:U('superadmin/admin_role/ajax_edit')}">
        <table width="100%" cellspacing="0">
            <thead>
            <tr>
                <th width="40"><input type="checkbox" name="checkall" class="J_checkall"></th>
                <th width="40">ID</th>
                <th>{:L('admininrole')}</th>
                <th>{:L('addtime')}</th>
                <th>{:L('status')}</th>
                <th width=100>{:L('operations_manage')}</th>
            </tr>
            </thead>
            <tbody>
            <volist name="list" id="val" >
                <tr>
                    <td align="center"><input type="checkbox" class="J_checkitem" value="{$val.id}"></td>
                    <td align="left">{$val.id}</td>
                    <td align="left"><span data-tdtype="edit" data-field="name" class="tdedit" data-id="{$val.id}">{$val.name}</span></td>
                    <td align="left">{$val.addtime|date='Y-m-d H:i:s',###}</td>
                    <td align="left">
                        <if condition="$val.status eq 1">
                        <span class="glyphicon glyphicon-ok" data-field="status" style=" color: #00CC00;"></span>
                        </if>
                        <if condition="($val.status eq 0)">
                            <span class="glyphicon glyphicon-remove" data-field="status" style="color: red;"></span>
                        </if>
                    </td>
                    <td align="left">
                        <a href="{:U('admin_role/edit', array('id'=>$val['id']))}">{:L('edit')}</a> ｜
                        <a href="{:U('admin_role/authorize', array('id'=>$val['id']))}">{:L('authorize')}</a>
                    </td>
                </tr>
            </volist>
            </tbody>
        </table>
    </div>
    <div class="btn_wrap_fixed">
        <!--<label class="select_all mr10"><input type="checkbox" name="checkall" class="J_checkall">{:L('select_all')}/{:L('cancel')}</label>-->
        <!--<input type="button" class="btn" data-tdtype="batch_action" data-acttype="ajax" data-uri="{:U('admin/delete')}" data-name="id" data-msg="{:L('confirm_delete')}" value="{:L('delete')}" />-->
        <div id="pages">
            {$page}
        </div>
    </div>
</div>
<include file="public:footer" />
</body>
<script>
    $(document).ready(function(){
        //glyphicon click事件
        $('.glyphicon').click(function(){
            var obj   = $(this);
            var is_ok = $(this).hasClass('glyphicon-ok');
            var url   = $('.table_list').attr('data-acturi');
            var field = obj.attr('data-field');
            var val   = is_ok ? 0 : 1;
            var source= $('.table_list').attr('data-source');
            var id    = $(this).parents('tr').find('td').eq(1).text();

            $.ajax({
                type:'post',
                dataType:'json',
                url:url,
                data:{field:field, val:val,id:id, source:source},
                success:function(res){
                    if(res.status)
                    {
                        if(is_ok) obj.removeClass('glyphicon-ok').addClass('glyphicon-remove').css({color:'red'});
                        if(!is_ok) obj.removeClass('glyphicon-remove').addClass('glyphicon-ok').css({color:'#00CC00'});
                    }
                }
            });

        });


    });
</script>
</html>